<jsp:useBean id="register" class="dasregistry.registryBean"	scope="page" />
<jsp:useBean id="coord" class="dasregistry.coordBean" scope="session" />
<jsp:directive.page	import="org.biojava.dasobert.dasregistry.DasCoordinateSystem" />
<jsp:directive.page import="org.biojava.dasobert.dasregistry.DasCoordSysComparator" />
<jsp:directive.page import="java.util.Comparator" />

<%@ page import="org.biojava.services.das.dao.Role" %>
<%@ page import="org.biojava.services.das.dao.RegistryUser" %>
<%@ page import="org.biojava.services.das.registry.UserManager" %>

<%@ include file="logincheck.jsp"%>



<% 
	

	String title="Create new Coordinate system";
 	String header= title;



%>

<!-- the sanger default header -->
<%@ include file="pagehead.jsp" %>    
<script language = "javascript" src="javascripts/alphabetLimitedDropdown.js">
  
    </script>



</head>
<body>
<%@ include file="pagebodystart.jsp" %>

<jsp:include page="openwindowscript.jsp" />

<div id="main">

<% if (! isAdmin) 
{ 
%>
You are not logged in as administrator. Only administrators can create
new coordinate systems.
<a href="login.jsp">login</a>
.

<% 
   } 
   else { 

%>





<h2>Already known coordinate systems</h2>
<p/>
<!--<p><%@ include file="sangertablestart.jsp"%>-->
<jsp:include  page="sangertablestart.jsp"/>

	<tr></tr>
	

		<!-- Organism -->
	<tr class="row1">
		<td valign="top">Filter Shown Coordinate Systems by Organism:</td>
		<td align="left"><input size="1" style="width: 30em;" id="textInputCoord" type = "text" value = "" 
        onkeyup="getData('textInputCoord','coordsDropdown.jsp', 'coordDiv')"/> 
    
<tr class="row2"><td align="left"></td><td  align="left">
    <div id="coordDiv">
     <select style="width: 30em;"><option value="">Start typing organism in textbox above.</option>
     </select>
      </div> </td></tr>
	
<jsp:include  page="sangertableend.jsp"/>
<a href="javascript:openWindow('listCoords.jsp','available coordinate systems',640,480)">show in separate window</a>
<p />

<hr/>

<h2>Create a new coordinate system</h2>

<form method="post" action="createcoordsysaction.jsp"
		name="create_form"><!-- name -->
<jsp:include  page="sangertablestart.jsp"/>

	
	<tr class="row1">
		<td>1.</td>
		<td>Choose an already existing name</td>
		<td><select name="name" size="1">
			<%
	   
	   String[] coords = coord.getNames();

	   int coordslength = 0;
	   if ( coords!= null) {
	      coordslength = coords.length;
	   }

	   for ( int i =0; i< coordslength; i++ ) {
	   %>
			<option value="<%=coords[i]%>" <% if (i==0) out.print("selected");%>><%=coords[i]%></value>
			<%
	   }
	%>
			
		</select></td>
		<td valign="top" align="right"><a
			href="help_reference.jsp#coordinatesystem">help</a><br />
		</td>
	</tr>

	<tr class="row2">
		<td>&nbsp;</td>
		<td valign="top">or create a new one</td>
		<td><input type="input" name="newName" size="20" /></td>
		<td>&nbsp;</td>
	</tr>




	<!-- coord sys type -->

	<tr class="row1">
		<td valign="top">2.</td>
		<td valign="top">Type of coordinate system</td>
		<td>
		<%
	  
	   String[] cats = null;
	   try {
	       cats = register.getCoordSysTypes();
	   } catch (Exception e) {
	       out.print(e.getMessage());	  
	   }
	   %> <select name="categories" size="3" multiple>

			<%
	   String category = request.getParameter("category");
   	   if ( category == null ){
		if ( cats != null ) 
		   category = cats[0];
	   } 
	   int catslength = 0;
	   if ( cats != null ) {
	      catslength = cats.length;
	   }
	   for ( int i =0; i< catslength; i++ ) {
	   %>
			<option value="<%=cats[i]%>"
				<% 
	   
		if ( category.equals(cats[i]))
			out.print(" selected ");
		
	   %>><%=cats[i]%></value>
			<%
	   }
	%>
			
		</select></td>
		<td valign="top" align="right"><a
			href="help_reference.jsp#category">help</a><br />
		</td>
	</tr>




	<!-- Organism -->
	<tr class="row2">
		<td valign="top">3.</td>
		<td valign="top">Organism</td>
		<td><input id="textInputOrganism" size="1" style="width: 30em;" type = "text" value = "" 
        onkeyup="getData('textInputOrganism','organisms.jsp', 'targetDiv')"> 
    <br>
    <br>

    <div id="targetDiv">
       <select style="width: 30em;"><option value="">Start typing organism in textbox above.</option>
     </select></div> 
		
		
		</td>
		<td valign="top" align="right"><a
			href="help_reference.jsp#organism">help</a><br />
		</td>
	</tr>


	<tr>
		<td colspan="4" valign="top" align="right"><input type="submit"
			value="Create"></td>
	</tr>
<jsp:include  page="sangertableend.jsp"/>

</form>
<%@ include file="sangertableend.jsp"%>




<%
}
%>

</div>
<%@ include file="sangerfooter.jsp"%>

